<?php

// Prevent much happening if this script is called directly
if ( !defined('INCS') ) exit;

// Sanitisation functions


/**
 * Encodes HTML safely for UTF-8. Use instead of htmlentities.
 *
 * @param string $var
 * @return string
 */
function html_encode($var)
{
    return htmlentities($var, ENT_QUOTES, 'UTF-8') ;
}



// for now, just length, but later, encoding and such.
function safe_for_logging( $unsafe, $num, $default_return )
{
    if ( !is_string( $unsafe ) ) return $default_return;

    if ( mb_strlen( $unsafe ) > $num )
    {
        $unsafe = mb_substr( $unsafe, 0, $num );
    }

    $safe = $unsafe;
    return $safe;
}

